package java8Test.function.lambda.part2;

import spring.po.User;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.function.Predicate;

/**
 * @author : yang.xp
 * @date : 2022/9/22 17:42
 * @description : 第对应的属性进行验证
 */
public class PredicateTest {

    private static Predicate<User> predicate1 = t -> t.getAge() == 5;
    private static Predicate<User> predicate2 = t -> t.getId() == 0;
    private static Predicate<User> predicate3 = t -> t.getName().equals("ff");

    private Runnable runnable = () -> System.out.println("dsaf");


    public static void main(String[] args) {
        User user = User.buildUser();
        System.out.println(predicate1.test(user));
        System.out.println(predicate1.and(predicate2).test(user));
        System.out.println(predicate1.negate().test(user));
        System.out.println(predicate1.or(predicate3).test(user));
        System.out.println(Predicate.isEqual(User.buildUser()).test(user));

        JButton jButton = new JButton();
        jButton.addActionListener(ActionEvent::getActionCommand);
//          不可以区分两个check
//        PredicateTest predicateTest = new PredicateTest();
//        predicateTest.check(x -> x > 5);
    }

    public void check(Predicate<Integer> integerPredicate) {

    }
    public void check(BooleanPre<Boolean> integerPredicate) {

    }
}

interface BooleanPre<T> {
    boolean test(Boolean integer);
}
